#e
#Title[GtFNgmF]
#Text[]
#Image[]
#BGM[]
#Player[FREE]
#PlayLevel[]
#BackGround[]
#ScriptVersion[2]

script_enemy_main {

    // ֐̎荞
    #include_function ".\usershot\lib_usershot.txt"
    #include_function ".\effectdata\Obj_EffectALL.txt"

    // XNvg܂ł̃pX̎擾
    let csd        = GetCurrentScriptDirectory();

    // G摜̃pX
    let imgBoss    = csd ~ "img\ExRumia.png";

    // G̖O摜̃pX
    let ename      = csd ~ "img\ename.png";

    // ʒu̐ݒ
    let xIni       = GetCenterX()  + 1;
    let yIni       = GetClipMinY() + 130;

    // e摜̃pX
    let shotData   = csd ~ "\usershot\data_usershot.txt";

    let textnamber = 0;

    @Initialize {

	LoadGraphic(imgBoss);
	SetTexture(imgBoss);

	SetLife(500);
	SetTimer(58);
	SetDamageRate(0,0);

	DrawTimer();				// c莞Ԃ̕\
	DrawTimerEx(2);				// c莞Ԃ̕\
	EnemyMarker01();			// Gl~[}[J[̕\
	LifeStockBar(9);			// cXyJ[h̕\
	LifeStock(9,0);				// cXyJ[h̕\
	LifeBar_A_01(0, 1.0, 0.0, true);	// Q[W̕\
	LifeCircleBar_A(1.0, 0.0, true);	// ~Q[W̕\
	//LifeCircleBar_Marker(0.5);		// ؂̕\
	DrawEnemyName(ename,0,16,true);		// G̖O̕\

	MagicCircle(false);
	SetRateScoreSystemEnable(false);
	LoadUserShotData(shotData);
	SetEffectForZeroLife(0, 0, 0);
	SetShotAutoDeleteClip(64, 64, 64, 64);

	MainTask();

    }

    @MainLoop {
	SetCollisionA(GetX, GetY, 32);
	SetCollisionB(GetX, GetY, 32);

	yield;
    }

    @DrawLoop {
	DrawGraphic(GetX, GetY);

	//=============================================================================================
	//  ̕\@vȂ̘͂gׂč폜ĂB
	//=============================================================================================
	SetFontColor(255,255,255,255,255,255);
	if(GetTimer<=50&&GetTimer>45) { DrawText("LifeBer01 "     , 250,  30           , 12, 255); }
	if(GetTimer<=45&&GetTimer>40) { DrawText("LifeStock "     ,  36,  56           , 12, 255); }
	if(GetTimer<=40&&GetTimer>35) { DrawText("DrawTimer "     , 320,  46           , 12, 255); }
	if(GetTimer<=35&&GetTimer>30) { DrawText(" DrawTimerEx"   , 250,  42           , 12, 255); }
	if(GetTimer<=30&&GetTimer>25) { DrawText(" LifeStockBer"  ,  86,  30           , 12, 255); }
	if(GetTimer<=25&&GetTimer>20) { DrawText(" DrawEnemyName" ,  86,  30           , 12, 255); }
	if(GetTimer<=20&&GetTimer>15) { DrawText("EnemyMarker "   , 134, 445           , 12, 255); }
	if(GetTimer<=15&&GetTimer>10) { DrawText("LifeCircleBer " ,  48, GetY-10       , 12, 255); }
	if(GetTimer<=10&&GetTimer> 5) { DrawText("Aura1 Aura2 "   ,  58, GetY-10       , 12, 255); }
	if(GetTimer<= 5&&GetTimer> 0) { DrawText("MagicCircleEx " ,  45, GetY-10       , 12, 255); }
	if(textnamber>=1&&textnamber<=4){ DrawText("eGtFNg ",  36, GetCenterY+120, 12, 255); }
	alternative(textnamber)
	case(1) { DrawText("g`Ԓ"          , 36, GetCenterY+134, 12, 255);                 }
	case(2) { DrawText("_^`@D"          , 36, GetCenterY+134, 12, 255);                 }
	case(3)	{ DrawText("_uX|C[`__", 36, GetCenterY+134, 12, 255);                 }
	case(4) { DrawText("Pj"                  , 36, GetCenterY+134, 12, 255);                 }
	alternative(textnamber)
	case(1) { DrawText("CreateObjShotC_T01"      , 36, GetCenterY+148, 12, 255);                 }
	case(2) { DrawText("CreateObjShotC_T02"      , 36, GetCenterY+148, 12, 255);                 }
	case(3)	{ DrawText("CreateObjShotC_T03"      , 36, GetCenterY+148, 12, 255);                 }
	case(4) { DrawText("CreateObjShotC_T04"      , 36, GetCenterY+148, 12, 255);                 }
	//=============================================================================================

    }

    @Finalize {
	//DeleteGraphic(imgBoss);
    }

    // C^XN
    task MainTask {

	yield;

	StandBy();

	Aura1( 8, 64, 64,128);	// I[̕\[1]
	Aura2(60,160, 32, 32);	// I[̕\[2]
	MagicCircleEx(true);	// @w̕\
	wait(60);

	Shot01();
	Shot02();
	Shot03();
	Shot04();
	Move();

    }

    // ʒuֈړ
    function StandBy {
	SetMovePositionRandom01(416, 464, 5, xIni, yIni, xIni, yIni);
	SetGraphicMove();
	wait(60);
	SetGraphicStop();
	wait(60);
	SetDamageRate(10,0);
    }

    // U(g ` Ԓ)
    function Shot01 {

	let a       = 0;
	let b       = [US_BALL_S_RED,US_BALL_M_RED,US_BALL_L_RED,US_BALL_SS_RED,US_RICE_M_RED,US_BALL_M_A_RED,0];
	let c       = [dRED01,dRED02,dRED03,dRED05,dRED13,dRED_Ha,0];
	let x       = 0;
	let eff     = dRED01;
	let graphic = US_BALL_S_RED;

	textnamber++;
	//Slow(2);

	loop(6) {
	    loop(8) {
		CreateObjShotC_T01(54+x, GetCenterY-30, 3, 90, 0, -3/60, 0, graphic, eff, 16, 90, true);
		x += 384/8;
		eff++;
		graphic++;
		SetGraphicPose();
		wait(2);
	    }
	    a++;
	    x = 0;
	    eff = c[a];
	    graphic = b[a];
	    SetGraphicStop();
	    wait(120);
	}
    }

    // U(_^ ` @D)
    function Shot02 {

	let a       = 0;
	let b       = [US_BALL_S_RED,US_BALL_M_RED,US_BALL_L_RED,US_BALL_SS_RED,US_RICE_M_RED,US_BALL_M_A_RED,0];
	let c       = [dRED01,dRED02,dRED03,dRED05,dRED13,dRED_Ha,0];
	let x       = 0;
	let eff     = dRED01;
	let graphic = US_BALL_S_RED;

	textnamber++;
	//Slow(2);

	loop(6) {
	    loop(8) {
		CreateObjShotC_T02(54+x, GetCenterY-30, 3, 90, 0, -3/60, 0, graphic, eff, 16, 90, true);
		x += 384/8;
		eff++;
		graphic++;
		SetGraphicPose();
		wait(2);
	    }
	    a++;
	    x = 0;
	    eff = c[a];
	    graphic = b[a];
	    SetGraphicStop();
	    wait(120);
	}
    }

    // U(_uX|C[ ` __)
    function Shot03 {

	let a       = 0;
	let b       = [US_BALL_S_RED,US_BALL_M_RED,US_BALL_L_RED,US_BALL_SS_RED,US_RICE_M_RED,US_BALL_M_A_RED,0];
	let c       = [dRED01,dRED02,dRED03,dRED05,dRED13,dRED_Ha,0];
	let x       = 0;
	let eff     = dRED01;
	let graphic = US_BALL_S_RED;

	textnamber++;
	//Slow(2);

	loop(6) {
	    loop(8) {
		CreateObjShotC_T03(54+x, GetCenterY-30, 3, 90, 0, -3/60, 0, graphic, eff, 16, 90, true);
		x += 384/8;
		eff++;
		graphic++;
		SetGraphicPose();
		wait(2);
	    }
	    a++;
	    x = 0;
	    eff = c[a];
	    graphic = b[a];
	    SetGraphicStop();
	    wait(120);
	}
    }

    // U(Pj)
    function Shot04 {

	let a       = 0;
	let b       = [US_BALL_S_RED,US_BALL_M_RED,US_BALL_L_RED,US_BALL_SS_RED,US_RICE_M_RED,US_BALL_M_A_RED,0];
	let c       = [dRED01,dRED02,dRED03,dRED05,dRED13,dRED_Ha,0];
	let x       = 0;
	let eff     = dRED01;
	let graphic = US_BALL_S_RED;

	textnamber++;
	//Slow(2);

	loop(6) {
	    loop(8) {
		CreateObjShotC_T04(54+x, GetCenterY-30, 3, 90, 0, -3/60, 0, graphic, eff, 16, 90, true);
		x += 384/8;
		eff++;
		graphic++;
		SetGraphicPose();
		wait(2);
	    }
	    a++;
	    x = 0;
	    eff = c[a];
	    graphic = b[a];
	    SetGraphicStop();
	    wait(120);
	}
    }

    // ړ
    function Move {

	textnamber++;
	let speed = 5;

	loop {
	    SetGraphicRight;
	    SetAngle(90);
	    SetSpeed(speed);
	    speed -= 0.5;
	    wait(1);
	}
    }

    // OtBbN̐ݒ
    sub SetGraphicStop  { SetGraphicRect(  0,  0, 64, 64); }
    sub SetGraphicPose  { SetGraphicRect( 64,  0,128, 64); }
    sub SetGraphicLeft  { SetGraphicRect(128,  0,192, 64); }
    sub SetGraphicRight { SetGraphicRect(192,  0,256, 64); }

    sub SetGraphicMove {
	if(GetSpeedX <  0) { SetGraphicLeft(); }
	else { SetGraphicRight(); }
    }

    // w t[ҋ@
    function wait(w) { loop(w){ yield; } }

}